/** * struts-layout core javascript * * All rights reserved. */ //////////debut modif pour la date 18/02/2009 // Extraction du code clavier tapé //----------------------------------------------------------------------------------------------- function getKeyPressed(eventObj) { var keyCode = document.all ? eventObj.keyCode : eventObj.which; return keyCode; } //----------------------------------------------------------------------------------------------- // Caractères autorisés pour un champ heure //----------------------------------------------------------------------------------------------- function timeKeysAllowed(eventObj) { /* * Caractères acceptés : * [0,9] : */ var keyCode = getKeyPressed(eventObj); if ( keyCode >= 48 && keyCode <= 57 ) return true; if ( keyCode == 58 ) return true; if ( keyCode < 32 ) return true; return false; } function printCalendar(day1, day2, day3, day4, day5, day6, day7, first, month1, month2, month3, month4, month5, month6, month7, month8, month9, month10, month11, month12, day, month, year) { document.write('
'); document.write(''); document.write(''); document.write(''); document.write(' '); document.write(' '); document.write(' '); document.write(' '); document.write(' '); document.write(''); document.write(''); document.write(''); document.write(''); document.write(' '); document.write(' '); document.write(' '); document.write(' '); document.write(' '); document.write(' '); document.write(' '); document.write(' '); document.write(' '); document.write(' '); document.write(' '); document.write(' '); document.write(' '); document.write(' '); document.write(' '); document.write(''); document.write(''); document.write('
'); // month document.write(''); // year document.write('"); document.write('   
Choix d\'une heure (hh:mm:ss)
' + computedcaldays[0] + '' + computedcaldays[1] + '' + computedcaldays[2] + '' + computedcaldays[3] + '' + computedcaldays[4] + '' + computedcaldays[5] + '' + computedcaldays[6] + '
'); document.write('
'); document.write('
'); } /** * Show the calendar */ function showCalendar(year, month, day, pattern, formName, formProperty, event, startYear, endYear) { try { if (document.forms[formName].elements[formProperty].disabled) { return; } } catch (e) { } if (startYear!=null) { var calyear = document.getElementById("calyear"); for (i = startYear; i <= endYear; i++) { calyear.options[i - startYear] = new Option(i,i); } calyear.options.length = endYear - startYear + 1; if ( startYear == endYear ) calyear.style.display="none"; } if(document.all) { // IE. var ofy=document.body.scrollTop; var ofx=document.body.scrollLeft; document.all.slcalcod.style.left = event.clientX+ofx+10; document.all.slcalcod.style.top = event.clientY+ofy+10; document.all.slcalcod.style.visibility="visible"; document.all.calmois.selectedIndex= month; } else if(document.layers) { // Netspace 4 document.slcalcod.left = e.pageX+10; document.slcalcod.top = e.pageY+10; document.slcalcod.visibility="visible"; document.slcalcod.document.caltitre.document.forms[0].calmois.selectedIndex=month; } else { // Mozilla var calendrier = document.getElementById("slcalcod"); var ofy=document.body.scrollTop; var ofx=document.body.scrollLeft; calendrier.style.left = event.clientX+ofx+10; calendrier.style.top = event.clientY+ofy+10; calendrier.style.visibility="visible"; document.getElementById("calmois").selectedIndex=month; } if (document.forms[formName].elements[formProperty].stlayout) { var lc_day = document.forms[formName].elements[formProperty].stlayout.day; var lc_month = document.forms[formName].elements[formProperty].stlayout.month; var lc_year = parseInt(document.forms[formName].elements[formProperty].stlayout.year); cal_chg(lc_day, lc_month, lc_year); } else { cal_chg(day, month, year); } // Traitement de la partie heure // ============================= try { var field = document.forms[formName].elements[formProperty]; var dateTimeValue = field.value; if ( field.size > 10 ) { if ( dateTimeValue != null ) { var dt = dateTimeValue.split(" "); if ( dt.length > 1 ) { document.getElementById("caltime").value = dt[1]; } } } else document.getElementById("caltimeline").style.display = "none"; } catch (e) { try { document.getElementById("caltimeline").style.display = "none"; } catch (e) { alert(e.message); } } if (document.all) { hideElement("SELECT"); } calformname = formName; calformelement = formProperty; calpattern = pattern; } function formatDate(day, month, year) { var date = ""; var pos = 0; var pattern; var previousPattern; var patternLength = 0; if (calpattern!=null && calpattern.length>0) { previousPattern = calpattern.charAt(0); while (pos <= calpattern.length) { if (pos < calpattern.length) { pattern = calpattern.charAt(pos); } else { pattern = ""; } if (pattern != previousPattern) { switch (previousPattern) { case 'y': date += padYear(year, patternLength); break; case 'M': date += padNumber(month, patternLength); break; case 'd': date += padNumber(day, patternLength); break; case '\'': // PENDING break; default: date += previousPattern; } previousPattern = pattern; patternLength = 0; } patternLength++; pos++; } } try { var valueTime = document.getElementById("caltime").value; if ( valueTime.length > 0 ) { valueTime += ":00:00:00"; var h = valueTime.split(":"); var msg = ""; if ( h[0] > 23 ) msg += "Heures incorrectes"; if ( h[1] > 59 ) msg += "Minutes incorrectes"; if ( h[2] > 59 ) msg += "Secondes incorrectes"; if (msg.length > 0) { alert(msg); return null; } date += " "; date += h[0]; date += ":" + h[1]; date += ":" + h[2]; } } catch (e) { } return date; }